<form method="POST"><table>
    Keyword  :<input type="text" name="key">.<br>
    Min Like :<input type="text" name="min">.<br>
    Max Like :<input type="text" name="max">.<br>
    
    <td>Company :</td>
    <td><select name="Company">
            <?php 
 require_once './model/db.php';
 $query ="SELECT * FROM companies";
 $companies= getData($query);
 ?>
            <?php foreach ( $companies as $company):?>
            <option value="<?php echo $company['id']; ?>">
                <?php echo $company['name'];?>
                <?php endforeach;?>
                </option>
        </select>
            </td><br>
           
            
            <td>App :</td>
    <td><select name="app">
            <?php 
 require_once './model/db.php';
 $query ="SELECT * FROM apps";
 $apps= getData($query);
 ?>
            <?php foreach ( $apps as $app):?>
            <option value="<?php echo $app['id']; ?>">
                <?php echo $app['name'];?>
                <?php endforeach;?>
                </option>
        </select>
        <input type="submit"name="submit"value="seach"><br>
            </td>
    
    
    </table>
</form>
<?php
require_once 'model/db.php';

$query = "SELECT * FROM pages LIMIT 50";
$pages = getData($query);
?>
<?php if (isset($_POST['submit'])): ?>
    <?php $keyword = $_POST['key']; ?>
    <?php $min = (double) $_POST['min']; ?>
    <?php $max = (double) $_POST['max']; ?>

    <table border ="1">
        <tr>
            <th>Pid</th>
            <th>Image</th>
            <th>ID</th>
            <th>Name</th>
            <th>Username</th>
            <th>Phone</th>
            <th>Like</th>

        </tr>
        <?php foreach ($pages as $page): ?>
        
            <?php if (empty($keyword)&&((int) $_GET . $page['likes'] >= ((int) $_POST['min'])) && ((int) $_GET . $page['likes']) <= ((int) $_POST['max'])): ?>
                <tr>
                    <td><?php echo $page['pid'] ?></td>
                    <td><img src='<?php echo $page['picture'] ?>'></td>
                    <td><?php echo $page['id'] ?></td>
                    <td><?php echo $page['name'] ?></td>
                    <td><?php echo $page['username'] ?></td>
                    <td><?php echo $page['phone'] ?></td>
                    <td><?php echo $page['likes'] ?></td> 
                </tr>
              <?php elseif((strstr($keyword, $page['name'])==0)&&((int)$page['likes'] >= ((int) $_POST['min'])) &&
                      ((int) $page['likes']) <= ((int) $_POST['max'])):?>
                <tr>
                    <td><?php echo $page['pid'] ?></td>
                    <td><img src='<?php echo $page['picture'] ?>'></td>
                    <td><?php echo $page['id'] ?></td>
                    <td><?php echo $page['name'] ?></td>
                    <td><?php echo $page['username'] ?></td>
                    <td><?php echo $page['phone'] ?></td>
                    <td><?php echo $page['likes'] ?></td> 
                </tr>
                  <?php endif; ?>

        <?php endforeach; ?>
    </table>
<?php endif; ?>